1. Field of the Invention
This invention pertains in general to a computer display controller and in particular to a display controller supporting both landscape and portrait display modes.
2. Background of the Invention
Most computer displays are refreshed in the same orderxe2x80x94from left to right and top to bottom. In a cathode ray tube (CRT) display, the electron beam scans across the display tube in this order. In a liquid crystal display (LCD), the charge or voltage, depending on the display type, is applied to the liquid crystal cells in this order.
Images are usually stored internally by the computer in the same order. The top left corner of the image is stored at a starting memory address in the display buffer. Subsequent portions of the image in the scan order are stored at subsequent memory addresses.
FIG. 1A illustrates the scan order on a landscape display 100. The display has an X-direction offset (i.e., width) of X-ofst 110 and a Y-direction offset (i.e., height) of Y-ofst 112. The location of an individual pixel on the display is identified by an (X, Y) coordinate, where (0, 0) is the upper left pixel 114, (X-ofst-1, 0) is the upper right pixel 116, (0, Y-ofst-1) is the lower left pixel 118, and (X-ofst-1, Y-ofst-1) is the lower right pixel 120.
When the display is oriented so that the starting memory address in the display buffer corresponds with the upper left corner of the display, the display is said to be in xe2x80x9cnormal mode.xe2x80x9d In normal mode, the memory address in the display memory corresponding an (X, Y) location on the display is the same for software executing on the CPU (MACPU) and the display controller (MADISP). More specifically, the memory address in the display buffer for a location (X, Y) on the display is described by the equation:
MACPU=MADISP=(Y*X-ofst)+X,
where the sum (Y*X-ofst)+X is the offset from the starting memory address.
However, if the display is rotated, then these two addresses become different. For example, assume the display is rotated 90 degrees counterclockwise. For purposes of this discussion, the rotated display is in xe2x80x9cportrait mode.xe2x80x9d After this rotation, the scan begins in the lower left corner and moves from bottom to top, left to right.
FIG. 1B illustrates the scan order on a portrait mode display 150. In portrait mode, Y-ofst 154 is larger than X-ofst 152. As with normal mode, the location of an individual pixel in portrait mode is described by an (X, Y) coordinate, and (0, 0) is the upper left pixel 156, (X-ofst-1, 0) is the upper right pixel 158, (0, Y-ofst-1) is the lower left pixel 162, and (X-ofst-1, Y-ofst-1) is the lower right pixel 160. X coordinates extending beyond X-ofst 152 define a Virtual display area 166. In this description, the X-direction offset for the Virtual display area is referred to as X-ofst(Virtual) 164 while the X-ofst for the real display area is referred to as X-ofst(Real) 152.
In portrait mode, memory addresses in the display buffer correspond to different (X, Y) positions on the display than in normal mode. For compatibility reasons, the display controller preferably treats the starting memory address as the first scan position, regardless of the display mode. Since the first scan position is now the lower left corner of the display, memory addresses for locations (X, Y) on the display are defined by the following equation:
MADISP=X*Y-ofst+((Y-ofst-1)xe2x88x92Y).
If, for example, software executing on the CPU needs to write to the upper left corner of the display (location (0,0)), the software should write to the memory address offset by Y-ofst-1 from the starting address.
However, it is not practical to force the software to write to different memory addresses depending on the orientation of the display. A special software program is needed to translate normal mode address requests into portrait mode addresses. The special program may require a large number of additional memory cycles to perform the translation. As a result, using the special software to perform a large number of address translations for read and write requests consumes significant computing resources and may make screen updating and drawing take ten times longer. For these reasons, it is undesirable to let software handle address translation.
Thus, when the display is in portrait mode there is a need to translate memory addresses produced by software into corresponding addresses in the display memory. A display translation from normal mode to portrait mode (i.e., a 90 degree counterclockwise rotation) is equivalent to swapping the X and Y coordinates and inverting the Y coordinate. The translation can be performed quickly in hardware if the X and Y values are known.
For example, address translation is relatively easy if the display is 1024xc3x971024 because each coordinate uses ten bits of the memory address. FIG. 2 is a block diagram 200 illustrating how to translate from normal mode to portrait mode using a fixed 1024xc3x971024 display. The addresses before translation, MACPU 210, and after translation, MADISP 212, are shown. To effect the translation, bits 0-9 of MACPU 210, which represent the X coordinate, are copied 214 to bits 10-19 of MADISP 212, which represent the Y coordinate. Similarly, bits 10-19 of MACPU 210, which represent the Y coordinate, are inverted and copied 216 to bits 0-9 of MADISP 212, which represent the X coordinate. The copying and inverting can quickly be performed by hardware.
However, most displays are not 1024xc3x971024. In fact, it is common for normal mode displays to have a 4:3 aspect ratio, meaning that the X-ofst is typically larger than the Y-ofst. In such a case, the coordinates must be calculated using the equations:
Y=the quotient of MACPU/X-ofst; and
X=the remainder of MACPU/X-ofst.
Since a division operation is computationally expensive, it is difficult to quickly translate an address from MACPU to MADISP.
Therefore, there is a need to maintain software compatibility in both normal and portrait display modes for displays of sizes other than, and including, 1024xc3x971024. More specifically, there is a need to quickly translate MACPU to MADISP that does not cause performance degradation. There is a corresponding need to quickly switch from normal mode to portrait mode. A solution that meets these needs should work with a range of display sizes.
The above needs are met by a display subsystem that supports both normal mode and portrait mode displays. In normal mode, the scan starts at the upper left corner of the display. In portrait mode, the display is rotated 90 degrees counterclockwise and the scan starts at the lower left comer of the display.
The display subsystem according to the present invention includes a display memory for holding data to be displayed. The subsystem also includes a display controller for receiving memory access requests from the central processing unit (CPU), or software executing on the CPU, and accessing the memory in response. The display controller also reads data from the display memory and provides it to the display.
The display memory preferably includes a normal mode display area and a portrait mode display area. The normal mode display area is defined by X-ofst and Y-ofst values. These values correspond to the number of pixels displayed by the display in the X and Y dimensions, where (0, 0) is the top left comer of the display. An address in the normal mode display area for a particular location (X, Y) on the display is determined by the equation (Y*X-ofst)+X.
The portrait mode display area is similarly defined by X-ofst(Real) and Y-ofst values as measured from the top left comer of the display. X-ofst(Real) is the true X-ofst for the display and is distinguished from X-ofst(Virtual), which is a value greater than X-ofst(Real) and equal to a power of two. The CPU generates addresses for particular locations in the portrait mode display area using the equation Y*X-ofst(Virtual)+X. Since the starting position in portrait mode is the lower left comer of the display, however, the address for an (X, Y) position from the perspective of the display controller is determined by the equation X*Y-ofst+((Y-ofst-1)xe2x88x92Y).
The display controller receives the memory access requests from the CPU. Preferably, the high address bit in the memory access request indicates whether the request is for the normal mode or the portrait mode display area. If the memory access request is for the portrait mode display area, the display controller preferably translates the address of the request into the corresponding address from the perspective of the display controller. Otherwise, the display controller passes the address to the memory without translation.
The display controller preferably includes address translation logic for translating the address from the CPU into the equivalent address from the perspective of the display controller. Since the address from the CPU was calculated using X-ofst(Virtual), the address translation logic can determine the value of the X coordinate from the address without performing a division operation. Preferably, the address translation logic includes an arrangement of adders, multiplexers, and gates that can quickly perform the translation for a range of Y-ofst values. In one embodiment, the logic includes four adders, two multiplexers, and two gates, although other embodiments may have different hardware. The hardware functions according to values held by a set of parameter registers. Software sets the values of the parameter registers to specify the Y-ofst values used by the address translation logic to translate addresses.
Accordingly, the present invention allows the display to be quickly and easily switched between normal mode and portrait mode. Since the display memory contains dual display areas, the utilized display area can be changed very quickly. Moreover, the use of the Virtual X-ofst allows the address translation logic to quickly translate addresses received from the CPU.